#include "myqtimerwin.h"
#include "ui_myqtimerwin.h"
#include <QDebug>
#include <unistd.h>
#include <QTime>

myqtimerwin::myqtimerwin(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::myqtimerwin)
{
    ui->setupUi(this);
    //把定时器的timeout信号与show_time关联
    connect(&mtimer,&QTimer::timeout,this,&myqtimerwin::show_time);
}

myqtimerwin::~myqtimerwin()
{
    delete ui;
}

void myqtimerwin::on_startBt_clicked()
{
    //启动定时器
    mtimer.start(1000);
}

void myqtimerwin::on_pushButton_2_clicked()
{
    mtimer.stop();
}

void myqtimerwin::show_time()
{
    QString t = QTime::currentTime().toString("hh:mm:ss");
    qDebug()<<t;
    ui->label->setText(t);
    ui->lcdNumber->display(t);
}
